FBCMS.alert = function(msg, title, callback){
    msg = '<div style="text-align:left;margin:10px;">' + msg + '</div>';
    var closeFun = function(){
        this.close();
        if (callback) {
            if (typeof callback === 'function') {
                callback();
            } else if (typeof callback === 'object') {
                callback.fn(callback.params);
            }
        }
    };
    Dialogs.alert(msg, {
        title: title || '信息',
        autosize: true,
        width: 300,
        height: 100,
        lightbox: true,
        button: {
            ok: ['确定', closeFun]
        },
        onShow: function(){
            $('div.dialog button').focus();
        }
    });
};

FBCMS.confirm = function(msg, title, callback){
    msg = '<div style="text-align:left;margin:10px;">' + msg + '</div>';
    var okFun = function(){
        this.close();
        if (callback) {
            if (typeof callback === 'function') {
                callback();
            } else if (typeof callback === 'object' && callback.ok_fn) {
                callback.ok_fn(callback.ok_params);
            }
        }
    };
    
    var closeFun = function(){
        this.close();
        if (callback) {
            if (typeof callback === 'function') {
                callback();
            } else if (typeof callback === 'object' && callback.no_fn) {
                callback.no_fn(callback.no_params);
            }
        }
    };
    
    Dialogs.confirm(msg, {
        title: title || '信息',
        autosize: true,
        width: 300,
        height: 100,
        lightbox: true,
        button: {
            ok: ['确定', okFun],
            cancel: ['取消', closeFun]
        },
        onShow: function(){
            $('div.dialog button').focus();
        }
    });
};

FBCMS.showWindow = function(msg, title, options){
    var btns = {};
    if (options.buttons) {
        for (var i = 0; i < options.buttons.length; i++) {
            var obj = options.buttons[i];
            btns['label' + i] = [obj.label, obj.fn];
        }
    }
    
    msg = '<div style="text-align:left;margin:10px;">' + msg + '</div>';
    Dialogs.opendialog(msg, {
        title: title || '信息',
        width: options.width || 500,
        height: options.height || 500,
        lightbox: true,
        bgcolor: options.bgcolor || '',
        closable: options.closable !== undefined ? options.closable : true,
        button: btns
    });
};

FBCMS.loading = function(msg){
	FBCMS.showWindow('<div style="text-align:center;width:100%;"><img src="' + ctx + '/images/loading.gif" width="32" height="32" align="middle" />　' + msg + '</div>', '提示', {
		closable: false,
		height: 50
	});
};

FBCMS.closeWindow = function(fun, time){
	setTimeout('Dialogs.close();', time || 0);
	setTimeout(fun, time || 0);
};